package game;

import java.awt.Dimension;
import java.awt.Point;

/**
 * GameType is the superclass for all types of games involving a chess board and chess pieces. It sets up the game at the start and enforces the rules.
 * 
 * @author Nicole Waldrum
 * @date January 30, 2010
 * @version 1.0
 * 
 * @author Mark Kelly
 * @date February 20, 2010
 * @version 2.0
 *
 */
public abstract class GameType implements MoveChecker, GameStateListener {
	// Class Variables
	protected static final Dimension DEFAULT_BOARD_SIZE = new Dimension(8,8);
	
	// Instance Variables
	
	protected GameState state;

	// this variable is only to allow the value to persist after the constructor to be used in setupBoard()
	protected Dimension boardSize; 
	
	/**
	 * Initializes a new instance of <tt>GameType</tt> with a default board size
	 */
	public GameType() {
		boardSize = GameType.DEFAULT_BOARD_SIZE;
	}
	
	/**
	 * Initializes a new instance of <tt>GameType</tt> with the specified board size
	 * 
	 * @param size the size of the <tt>ChessBoard</tt> used for this <tt>GameType</tt>
	 */
	public GameType(Dimension boardSize) {
		this.boardSize = boardSize;
	}
	
	/**
	 * Associates this instance of GameType with a GameState. <b>This method must be invoked before any other methods.</b>
	 * 
	 * @param gameState the GameState to associate
	 */
	public void setGameState(GameState gameState) {
		this.state = gameState;
		gameState.addGameStateListener(this);
	}
	
	/**
	 * Checks if the conditions for winning this type of game have been met.
	 * @param team TODO
	 */
	public abstract boolean hasWon(Team team);
	
	/**
	 * Sets up the board and pieces for this type of game.
	 */
	public abstract void setupBoard();

	/**
	 * Performs any actions that are necessary after a Piece has been moved.
	 * 
	 * @param p the piece that was moved
	 */
	public abstract void pieceMoved(Piece p);
	
	public void gameStarted(){
	}
	
	public abstract boolean movePiece (Point start, Point dest);
}
